/**
 * @description 抽离对象指定的属性
 * @param {Object} source - 源对象
 * @param {String[]} attrs - 需要抽离的属性
 */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function pickProps(source: { [x: string]: any }, attrs: string[]) {
  const target = {};

  for (const k in source) {
    if (attrs.includes(k)) {
      target[k] = source[k];
    }
  }
  return target;
}

/**
 * @description 去除对象指定的属性
 * @param {Object} source - 源对象
 * @param {String[]} attrs - 要去除的属性
 */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function omitProps(source: { [key: string]: any }, attrs: string[]) {
  const target = {};

  for (const k in source) {
    if (!attrs.includes(k)) {
      target[k] = source[k];
    }
  }
  return target;
}
